﻿$(function(){//延迟加载
	var userId=$('#userId').val();
	var dflag=0;
	
	$('#birthday').click(function(){
		$(this).datebox();
		dflag=1;
	});
	
	$('#comedituser').click(function(){
		if(!$('#st1').form('validate')){
			alert('资料不完整!');
			return
		}
		var password=$('#password').val();
		var departmentId=$('#depart').combobox('getValue');
		var email=$('#email').val();
		var tel=$('#tel').val();
		var loctel=$('#loctel').val();
		var usercode=$('#usercode').val();
		var roleId=$('#roleId').combobox('getValue');
		var birthday=null;
		if(dflag==1){
			birthday=$('#birthday').datebox('getValue');
		}else{//未变更
			birthday='';
		}
//		alert(birthday);
		$.ajax({
			url:'edituser',
			method:'POST',
			data:{
				userId:userId,
				departmentId:departmentId,
				password:password,
				email:email,
				tel:tel,
				loctel:loctel,
				usercode:usercode,
				roleId:roleId,
				birthday:birthday
			},
			success:function(data){
				alert(data.msg);
				parent.addTab('员工信息编辑','touserdetail?userId='+userId);	
			}
		});
		
	});
	
});